﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Views;

namespace Presenters
{
    /// <summary>
    /// Presenter for the Select Service Plug in page of the Add Database wizard
    /// </summary>
    public class SelectServerPluginPresenter : PresenterBase<ISelectServerPluginView>
    {
        /// <summary>
        /// Initialise the Select Server Plugin presenter
        /// </summary>
        /// <param name="view"></param>
        public SelectServerPluginPresenter(ISelectServerPluginView view)
            : base(view)
        {
        }

        /// <summary>
        /// Load available plug ins into the view
        /// </summary>
        public void LoadPlugins()
        {
            View.AvailableServerPlugins = Services.ServersService.GetServerPluginList();
        }

        /// <summary>
        /// Validate the Select Server Plug in page
        /// </summary>
        /// <returns>True if a valid server plug in is selected</returns>
        public bool Validate()
        {
            bool valid = false;

            if (View.SelectedServerPluginID != Guid.Empty)
            {
                // We have a valid Guid so a plug in must be selected
                valid = true;
            }
            else
            {
                ViewManager.ViewFactory.DisplayError("Please select a server plugin to continue", "Select Plugin");
            }

            return valid;
        }
    }
}
